package reit.ass3;

import java.util.ArrayList;
import java.util.List;

import reit.parser.repairinfo.AssetContentsRepairDetails.AssetContent.Materials.Material;


/**
 * The Class RepairMaterialInformation.
 */
class RepairMaterialInformation { 

	/** The  name. */
	private final String mName;

	/** The  materials. */
	private final List<RepairMaterial> mMaterials;

	/**
	 * Instantiates a new repair material information.
	 *
	 * @param name the name
	 * @param material the material
	 */
	public RepairMaterialInformation(final String name,
			final List<reit.parser.repairinfo.AssetContentsRepairDetails.AssetContent.Materials.Material> material) {
		this.mName = name;
		this.mMaterials = createRepairMaterialList(material);
	}

	/**
	 * Gets the materials for repair.
	 *
	 * @return the mMaterials
	 */
	//TODO: why is this diffrent from assetContent line 51
	public List<RepairMaterial> getMaterials() {
		return mMaterials;
	}


	/**
	 * Gets the name.
	 *
	 * @return the mName
	 */
	public String getName() {
		return mName;
	}

	/**
	 * Creates the repair material list.
	 *
	 * @param material the material
	 * @return the list
	 */
	private List<RepairMaterial> createRepairMaterialList(final List<reit.parser.repairinfo.AssetContentsRepairDetails.AssetContent.Materials.Material> material){
		List<RepairMaterial> result = new ArrayList<RepairMaterial>();
		for(Material m : material){
			result.add(new RepairMaterial(m.getName(), m.getQuantity()));
		}
		return result;
	}

}
